
public class Complex{
	
	private double real;
	private double im;

	public Complex(double real, double im){
		this.real = real;
		this.im = im;
	}
	
	public Complex(double angle){
		this.real = Math.cos(angle);
		this.im = Math.sin(angle);
	}
	
	public void setReal(double real){
		this.real = real;
	}
	public double getReal(){
		return this.real;
	}
	public void setIm(double im){
		this.im = im;
	}
	public double getIm(){
		return this.im;
	}
	
	public double getNorm(){
		return Math.sqrt(this.real*this.real + this.im*this.im);
	}
	
	public double getAngle(){
		double p = 0;
		if(this.real < 0 && this.im > 0)
			p = Math.PI;
		else if(this.real < 0 && this.im < 0)
			p = -Math.PI;
		return Math.atan(this.im / this.real) + p;
	}
	
	public String toString(){
		return this.real + " i*" + this.im;
	}
}

